@extends('admin.base')
@section('content')
    <!--面包屑导航 开始-->
    <div class="crumb_warp">
        <!--<i class="fa fa-bell"></i> 欢迎使用登陆网站后台，建站的首选工具。-->
        <i class="fa fa-home"></i> <a href="{{url('admin')}}">首页</a> &raquo; <a href="#">网站配置管理</a> &raquo; 添加网站配置
    </div>
    <!--面包屑导航 结束-->

	<!--结果集标题与导航组件 开始-->
	<div class="result_wrap">
        <div class="result_title">
            <h3>快捷操作</h3>
            @if (count($errors) > 0)
                <div class="mark">
                    <ul>
                        @if(is_object($errors))
                            @foreach ($errors->all() as $error)
                                <li>{{ $error }}</li>
                            @endforeach
                        @else
                            <li>{{ session('errors') }}</li>
                        @endif
                    </ul>
                </div>
            @endif
        </div>
        <div class="result_content">
            <div class="short_wrap">
                <a href="{{url('admin/config/create')}}"><i class="fa fa-plus"></i>添加网站配置</a>

            </div>
        </div>
    </div>
    <!--结果集标题与导航组件 结束-->
    
    <div class="result_wrap">
        <form action="{{url('admin/config')}}" method="post">
            {{csrf_field()}}
            <table class="add_tab">
                <tbody>
                <tr>
                    <th><i class="require">*</i>网站名称：</th>
                    <td>
                        <input type="text" name="site_name" value="">
                    </td>
                </tr>
                <tr>
                    <th>网站描述：</th>
                    <td>
                        <textarea name="site_describe"></textarea>
                    </td>
                </tr>
                <tr>
                    <th><i class="require">*</i>网站logo：</th>
                    <td>
                        <input type="text" name="logo" id="logo"  value="{{old('logo')}}" >
                        <input type="file" name="file_upload" id="file_upload" value="">
                        <p><img src="" alt="" id="img1" style="width:100px" hidden></p>
                        <script type="text/javascript">
                            $(function () {
                                $("#file_upload").change(function () {
                                    $('img1').show();
                                    uploadImage();
                                });
                            });
                            function uploadImage() {
//                            判断是否有选择上传文件
                                var imgPath = $("#file_upload").val();
                                if (imgPath == "") {
                                    alert("请选择上传图片！");
                                    return;
                                }
                                //判断上传文件的后缀名
                                var strExtension = imgPath.substr(imgPath.lastIndexOf('.') + 1);
                                if (strExtension != 'jpg' && strExtension != 'gif'
                                        && strExtension != 'png' && strExtension != 'bmp') {
                                    alert("请选择图片文件");
                                    return;
                                }
                                var formData = new FormData($('#art_form')[0]);
                                $.ajax({
                                    type: "POST",
                                    url: "/admin/upload",
                                    data: formData,
                                    async: true,
                                    cache: false,
                                    contentType: false,
                                    processData: false,
                                    success: function(data) {
                                        $('#img1').attr('src','/'+data);
                                        $('#img1').show();
                                        $('#art_thumb').val(data);
                                    },
                                    error: function(XMLHttpRequest, textStatus, errorThrown) {
                                        alert("上传失败，请检查网络后重试");
                                    }
                                });
                            }
                        </script>
                    </td>
                </tr>
                <tr>
                    <th><i class="require">*</i>网站备案号：</th>
                    <td>
                        <input type="text" name="record_number" value="" class="lg">
                    </td>
                </tr>
                <tr>
                    <th><i class="require">*</i>网站地址：</th>
                    <td>

                        <input type="text" name="company_address" value="" class="lg">

                    </td>
                </tr>
                <tr>
                    <th><i class="require">*</i>版权信息：</th>
                    <td>
                        <input type="text" name="copyight" value="" class="lg">
                    </td>
                </tr>


                    <tr>
                        <th></th>
                        <td>
                            <button type="submit" class="btn btn-primary">添加</button>
                            <button type="submit" class="btn btn-primary" onclick="history.go(-1)">返回</button>
                            
                        </td>
                    </tr>
                </tbody>
            </table>
        </form>
    </div>

@endsection